home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / TCL1 / __MANDEL / MANDELBR / CMANDELR.C < prev    next >
Text File  |  1992-03-28  |  2KB  |  104 lines

  1. //    CMandelRectPhase.c
  2.  
  3. #include "CMandelRectPhase.h"
  4.  
  5. extern long gTickLimit;
  6.  
  7. void
  8. CMandelRectPhase::IMandelRectPhase(CMandelDoc *theDoc, CMandelPhase *theNextPhase,
  9.     short theH, short theV, short theNCols, short theNRows)
  10. {
  11.     CMandelPhase::IMandelPhase(theDoc, theNextPhase);
  12.     
  13.     itsScale    = theDoc->itsScale;
  14.     itsHStart    = theDoc->itsHStart + (double)theH * itsScale;
  15.     itsVStart    = theDoc->itsVStart - (double)theV * itsScale;
  16.     itsMaxDwell    = theDoc->itsMaxDwell;
  17.     itsDwellsH    = theDoc->itsDwellsH;
  18.     itsVOffset    = (((long)theDoc->itsWidth - 1) - theNCols) * sizeof(TDwell);
  19.     itsNRows    = theNRows;
  20.     itsNCols    = theNCols;
  21.     itsIndex    = ((long)theV * theDoc->itsWidth + theH) * sizeof(TDwell);
  22.     
  23.     itsHTemp    = itsHStart;
  24.     itsNTemp    = itsNCols;
  25. }
  26.  
  27. CMandelPhase *
  28. CMandelRectPhase::Perform(void)
  29. {
  30.     asm
  31.     {
  32.         movem.l        d3-d7/a3,-(sp)
  33.         fmovem        fp4-fp7,-(sp)
  34.         
  35.         move.l        (this),a3
  36.         
  37.         fmove.x        CMandelRectPhase.itsScale(a3),fp0
  38.         fmove.x        CMandelRectPhase.itsVStart(a3),fp7
  39.         move.w        CMandelRectPhase.itsVOffset(a3),d3
  40.         move.w        CMandelRectPhase.itsNCols(a3),d4
  41.         move.w        CMandelRectPhase.itsMaxDwell(a3),d5
  42.         move.w        CMandelRectPhase.itsNRows(a3),d7
  43.         
  44.         move.l        CMandelRectPhase.itsDwellsH(a3),a1
  45.         move.l        (a1),a0
  46.         adda.l        CMandelRectPhase.itsIndex(a3),a0
  47.         fmove.x        CMandelRectPhase.itsHTemp(a3),fp6
  48.         move.w        CMandelRectPhase.itsNTemp(a3),d6
  49.         bra            @0
  50.         
  51.     @s:
  52.         fmove.x        CMandelRectPhase.itsHStart(a3),fp6
  53.         move.w        d4,d6
  54.     @0:
  55.         move.l        Ticks,d0
  56.         cmp.l        gTickLimit,d0
  57.         bgt            @4
  58.  
  59.         move.w        d5,d0
  60.         fmove.x        fp6,fp2            ; Z.a = Z0.a
  61.         fmove.x        fp7,fp5            ; Z.b = Z0.b
  62.         bra            @2
  63.     @1:
  64.         fsub.x        fp3,fp2
  65.         fmul.x        fp4,fp5
  66.         fscale.x    #1.0,fp5
  67.         fadd.x        fp6,fp2            ; ZZ.a += Z0.a
  68.         fadd.x        fp7,fp5            ; ZZ.b += Z0.b
  69.     @2:
  70.         fmove.x        fp2,fp4            ; Z = ZZ
  71.         fmul.x        fp4,fp2            ; temp = ZZ.a * ZZ.a + ZZ.b * ZZ.b
  72.         fmove.x        fp5,fp3
  73.         fmul.x        fp5,fp3
  74.         fmove.x        fp2,fp1
  75.         fadd.x        fp3,fp1
  76.         fcmp.x        #4.0,fp1
  77.         fbgt        @3
  78.         dbra        d0,@1
  79.     @3:
  80.         move.w        d0,(a0)+
  81.         fadd.x        fp0,fp6
  82.         dbra        d6,@0
  83.  
  84.         fsub.x        fp0,fp7
  85.         adda.w        d3,a0
  86.         dbra        d7,@s
  87.  
  88.         move.l        CMandelRectPhase.itsNextPhase(a3),d0
  89.         bra            @5
  90.     @4:
  91.         fmove.x        fp6,CMandelRectPhase.itsHTemp(a3)
  92.         fmove.x        fp7,CMandelRectPhase.itsVStart(a3)
  93.         move.w        d6,CMandelRectPhase.itsNTemp(a3)
  94.         move.w        d7,CMandelRectPhase.itsNRows(a3)
  95.         suba.l        (a1),a0
  96.         move.l        a0,CMandelRectPhase.itsIndex(a3)
  97.         clr.l        d0
  98.     @5:
  99.         fmovem        (sp)+,fp4-fp7
  100.         movem.l        (sp)+,d3-d7/a3
  101.     }
  102. }
  103.  
  104.